package com.store.app.widget;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;


import com.store.app.R;
/**
 * Created by lushan
 * on 2016/4/5 15:09 .
 * 分享Dialog
 */
public class ShareDialog extends Dialog implements View.OnClickListener {

    private TextView btn_friendCircle;
    private TextView btn_weixin_friend;
    private TextView btn_qq_friend;
    private TextView btn_qq_zone;

    private TextView btn_cancle;//取消
    private OnShareClickListener listener;
    private Activity mActivity;

    public ShareDialog(Activity activity, OnShareClickListener l) {
        super(activity, R.style.dialog_with_alpha);
        this.mActivity = activity;
        this.listener = l;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_share);
        DisplayMetrics metric = new DisplayMetrics();
        mActivity.getWindowManager().getDefaultDisplay().getMetrics(metric);
        WindowManager.LayoutParams p = getWindow().getAttributes();
        p.width = (int) (metric.widthPixels);
        Window window = getWindow();
        window.setAttributes(p);
        window.setGravity(Gravity.BOTTOM);
        window.setWindowAnimations(R.style.Umengstyle);
        setCancelable(true);
        this.setCanceledOnTouchOutside(true);

        initView();
    }

    void initView() {
        btn_friendCircle = (TextView) findViewById(R.id.btn_friendCircle);
        btn_weixin_friend = (TextView) findViewById(R.id.btn_weixin_friend);
        btn_qq_friend = (TextView) findViewById(R.id.btn_qq_friend);
        btn_qq_zone = (TextView) findViewById(R.id.btn_qq_zone);

        btn_cancle = (TextView) findViewById(R.id.btn_cancle);

        btn_friendCircle.setOnClickListener(this);
        btn_weixin_friend.setOnClickListener(this);
        btn_qq_friend.setOnClickListener(this);
        btn_qq_zone.setOnClickListener(this);
        btn_cancle.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_friendCircle:
                listener.FriendCircle(v);//朋友圈
                break;
            case R.id.btn_weixin_friend:
                listener.WeChatFriends(v);//微信好友
                break;
            case R.id.btn_qq_friend:
                listener.QQFriends(v);//QQ好友
                break;
            case R.id.btn_qq_zone:
                listener.QQZone(v);//QQ空间
                break;
            case R.id.btn_cancle:
                dismiss();
                break;
        }
    }

    public interface OnShareClickListener {
        void FriendCircle(View v);//朋友圈

        void WeChatFriends(View v);//微信好友

        void QQFriends(View v);//QQ好友

        void QQZone(View v);//QQ空间

        void Copy(View v);//复制链接

        void SMS(View v);//短信

        void Email(View v);//邮件
    }
}
